package com.oocl.sorter;

public class BinarySearch {
	
	//返回索引
	public static int search(int[] arr, int index){
		int min = 0;
		int max = arr.length-1;
		while(min<max){
			int mid = (min+max)/2;
			if(arr[mid] == index){
				return mid;
			}else if(index < arr[mid]){
				max = mid-1;                ///////////////////key
			}else{
				min = mid+1;				///////////////////key
			}
			
		}
		return -1;							/////////////////key
	}
}
